package com.mes.web.controller.biz;

import java.util.List;
import java.util.HashMap;
import java.util.Map;
import com.mes.common.annotation.Log;
import com.mes.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.mes.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mes.common.enums.BusinessType;
import com.mes.common.utils.poi.ExcelUtil;
import com.mes.framework.cache.DictUtils;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.mes.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.mes.biz.domain.BizPaymentDetail;
import com.mes.biz.service.BizPaymentDetailService;

/**
 * 收款明细Controller
 * @author wy
 * @email wy
 * @date 2023-07-10
 */
@RestController
@RequestMapping("/biz/bizPaymentDetail")
public class BizPaymentDetailController extends BaseController {

    @Autowired
    private BizPaymentDetailService bizPaymentDetailService;

    /**
     * 查询收款明细列表
     */
    @PreAuthorize("@ss.hasPermi('biz:bizPaymentDetail:list')")
    @GetMapping("/list")
    public R<PageInfo> list(BizPaymentDetail bizPaymentDetail, HttpServletRequest request, HttpServletResponse response) {
        bizPaymentDetail.setPage(new PageDomain(request, response));
        return R.data(bizPaymentDetailService.findPage(bizPaymentDetail));
    }

    /**
     * 获取收款明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:bizPaymentDetail:query')")
    @GetMapping(value = "/{id}")
    public R<BizPaymentDetail> detail(@PathVariable("id") String id) {
        return R.data(bizPaymentDetailService.get(id));
    }

    /**
     * 新增收款明细
     */
    @PreAuthorize("@ss.hasPermi('biz:bizPaymentDetail:add')")
    @Log(title = "收款明细", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  BizPaymentDetail bizPaymentDetail) {
        return R.status(bizPaymentDetailService.save(bizPaymentDetail));
    }

    /**
     * 修改收款明细
     */
    @PreAuthorize("@ss.hasPermi('biz:bizPaymentDetail:edit')")
    @Log(title = "收款明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated BizPaymentDetail bizPaymentDetail) {
        return R.status(bizPaymentDetailService.save(bizPaymentDetail));
    }

    /**
     * 删除收款明细
     */
    @PreAuthorize("@ss.hasPermi('biz:bizPaymentDetail:remove')")
    @Log(title = "收款明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids) {
        return R.status(bizPaymentDetailService.deleteBizPaymentDetailByIds(ids));
    }


    /**
     * 导出收款明细列表
     */
    @PreAuthorize("@ss.hasPermi('biz:bizPaymentDetail:export')")
    @Log(title = "收款明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(BizPaymentDetail bizPaymentDetail) {
        List<BizPaymentDetail> list = bizPaymentDetailService.findList(bizPaymentDetail);
        ExcelUtil<BizPaymentDetail> util = new ExcelUtil<BizPaymentDetail>(BizPaymentDetail.class);
        return util.exportExcel(list, "收款明细数据");
    }

    /**
     * 根据字典类型查询字典数据信息等其他自定义信息
     */
    @GetMapping(value = "/getInitData/{dictTypes}")
    public R getInitData(@PathVariable String dictTypes) {
        Map<String, Object> dataMap = new HashMap<String, Object>();
        dataMap.putAll(DictUtils.getMultiDictList(dictTypes));
        return R.data(dataMap);
    }

}
